package com.njlime.cms.repository.app;

import com.njlime.cms.entities.InformationUp;
import com.njlime.core.base.repository.impl.BaseDaoImpl;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Dean on 2017-10-10.
 */
@Repository
public class AppInformationUpDaoImpl extends BaseDaoImpl<InformationUp> {

    /**
     * 获取评论点赞数
     *
     * @param commentId
     * @param userId
     * @return
     */
    public int userUpCount(int commentId, int userId) {
        StringBuilder sb = new StringBuilder();
        List<Object> arrList = new ArrayList<Object>();
        sb.append("select * from t_information_up where comment_id  = ? and up_user_id = ?");
        arrList.add(commentId);
        arrList.add(userId);
        return getListJdbcSize(sb.toString(), arrList);
    }

    /**
     * 删除
     *
     * @param commentId
     * @param userId
     * @return
     */
    public int del(Integer commentId, Integer userId) {
        StringBuilder sb = new StringBuilder();
        List<Object> arrList = new ArrayList<Object>();
        sb.append(" DELETE FROM t_information_up WHERE comment_id = ? and up_user_id = ?");
        arrList.add(commentId);
        arrList.add(userId);
        return updateJdbc(sb.toString(), arrList);
    }
}
